var fs = require('fs')
function readFile_promise(path) {
  return new Promise((resolve, reject) => {
    fs.readFile(path, (err, data) => {
      if (err) {
        reject(err)
      } else {
        resolve(data)
      }
    })
  })
}
readFile_promise('../bar.txt')
  .then(res => console.log(res.toString())) // 返回文件内容 bar
  .then(res => console.log(res)) // undefined


  readFile_promise('../baz.txt')
    .then(res => {
      return readFile_promise('../foo.txt')
    })
    .then(res => {
      console.log(res.toString()) // foo
    })